chore: bring examples under pyright#43
Merged
Merged
Conversation
VS Code's Pylance surfaces type errors on the example files because they're outside pyright's `[tool.pyright].include` (currently src, tests). Pylance reads the project config, sees the example file isn't in scope, falls back to inferred typing that loses pydantic / openai SDK type info, and emits unknown-member squiggles. Two changes: - pyproject.toml: extend pyright's include to ["src", "tests", "examples"] so the project-wide check covers them and Pylance inherits the same scope. - examples/00-hello-world/main.py: with pyright now seeing the example, the trace() observer's `event.post_state.sources` access becomes a real error. `NodeEvent.post_state` is typed as the base `State`, not the subclass `PipelineState`. Adding an `isinstance(event.post_state, PipelineState)` check narrows the type for static checkers and acts as a defensive guard against any foreign-state observer event the engine might dispatch. All other examples (01-05) come up pyright-clean under project-wide context. Confirmed via uv run pyright = 0 errors after the changes.
There was a problem hiding this comment.
Pull request overview
This PR brings the examples/ directory under the project’s strict Pyright configuration and updates the hello-world observer example so its state access is statically type-safe.
Changes:
- Adds
examplesto[tool.pyright].include. - Narrows
event.post_statetoPipelineStatebefore readingsourcesin the hello-world trace observer.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
pyproject.toml |
Expands Pyright coverage to include example files. |
examples/00-hello-world/main.py |
Adds an isinstance guard so observer state access is type-safe. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
2 tasks
chris-colinsky
added a commit
that referenced
this pull request
May 17, 2026
The release workflow's ``Sync deps`` step ran ``uv sync --frozen --all-extras`` without ``--group examples``, so ``openai`` was missing from the venv and the four ``tests/test_examples_smoke.py`` cases failed at module-load time with ``ModuleNotFoundError``. ``ci.yml`` has been doing the right thing since #43; this brings ``release.yml`` in line. Surfaced when the v0.6.0 tag fired the workflow for the first time since #43 landed. The drift sat dormant because release.yml only runs on tag pushes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
VS Code's Pylance surfaces type errors on the example files because they're outside pyright's
[tool.pyright].include(currentlysrc,tests). Pylance reads the project config, sees the example file isn't in scope, falls back to inferred typing that loses pydantic / openai SDK type info, and emits unknown-member squiggles.Two changes:
pyproject.toml: extend pyright'sincludeto["src", "tests", "examples"]so the project-wide check covers them and Pylance inherits the same scope.examples/00-hello-world/main.py: with pyright now seeing the example, thetrace()observer'sevent.post_state.sourcesaccess becomes a real error.NodeEvent.post_stateis typed as the baseState, not the subclassPipelineState. Adding anisinstance(event.post_state, PipelineState)check narrows the type for static checkers and acts as a defensive guard against any foreign-state observer event the engine might dispatch (e.g., the LLM-provider span events the comment above already mentions).All other examples (01-05) come up pyright-clean under project-wide context once they're in scope; no per-file changes needed.
Test plan
uv run pyright— 0 errors (was 0 before this PR because examples were out of scope; now 0 with examples in scope).uv run pytest— 503 pass, 84 skipped, 0 failed.examples/00-hello-world/main.py— the two Pylance "Cannot access attribute 'sources' for class 'State'" errors that surfaced after PR feat(llm): structured output (proposal 0016) #42 merged are gone.Follow-up
Fast-follow to PR #42 (proposal 0016 structured output). Doc/example surface only — no behavioral changes; runtime path of every example unchanged.